package com.sljy.hzk.ui.exam;

import android.content.Intent;
import android.widget.TextView;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.sljy.hzk.R;
import com.sljy.hzk.annotation.ActivityInfo;
import com.sljy.hzk.base.BaseActivity;
import com.sljy.hzk.base.UserInfo;
import com.sljy.hzk.entity.ExamInfosEntity;
import com.sljy.hzk.entity.ExamPriceEntity;
import com.sljy.hzk.entity.UserEntity;
import com.sljy.hzk.net.BaseCallBack;
import com.sljy.hzk.net.HttpHeper;
import com.sljy.hzk.net.service.ExamService;
import com.sljy.hzk.view.ProgressView;
import com.trello.rxlifecycle2.android.ActivityEvent;

import butterknife.BindView;

@ActivityInfo(layout = R.layout.activitye_exam_price, isShowActionBar = true,title = "综合评估",rightIcRes = R.drawable.homepage)
public class ExamPriceActivity extends BaseActivity {
    @BindView(R.id.pointText)
    TextView pointText;
    @BindView(R.id.maxScore)
    TextView maxScore;
    @BindView(R.id.minScore)
    TextView minScore;
    @BindView(R.id.stateText)
    TextView stateText;
    @BindView(R.id.allNumText)
    TextView allNumText;
    @BindView(R.id.successText)
    TextView successText;
    @BindView(R.id.failText)
    TextView failText;
    @BindView(R.id.progressView)
    ProgressView progressView;
    UserEntity user;
    @Override
    protected void init() {
        user = UserInfo.getUserInfo();
        HttpHeper.get().create(ExamService.class)
                .getPriceInfo(user.getCpId())
                .compose(this.bindUntilEvent(ActivityEvent.DESTROY))
                .compose(getThread())
                .subscribe(new BaseCallBack<ExamPriceEntity>(this) {
                    @Override
                    public void onCallBackSuccess(ExamPriceEntity data) {
                        pointText.setText("合格率 | "+data.getQualificationRate()+"%");
                        maxScore.setText(data.getMaxScore());
                        minScore.setText(data.getMinScore());
                        stateText.setText(data.getRateStr());
                        allNumText.setText(data.getTotalNumber());
                        successText.setText(data.getPassNumber());
                        failText.setText(data.getNotPassNumber());
                    }

                    @Override
                    public void onFail(String mes) {
                        showToast(mes);
                    }
                });

    }
}
